package com.example.libraryapp.activity.favorite;

import com.example.libraryapp.bean.Book;
import com.example.libraryapp.bean.response.BaseResponse;
import com.example.libraryapp.network.base.BaseHttpHandler;
import com.example.libraryapp.network.base.BasePresenter;

import java.util.List;

/**
 * @author 伍凯铭
 * @since 2020/6/22
 */
public class FavoritePresenterIml extends BasePresenter<FavoriteContract.View> implements FavoriteContract.Presenter{

    @Override
    public void getFavorite(long userId) {
        super.doRequest(getRequestService().getFavorite(userId),new FavoriteHandler());
    }

    class FavoriteHandler extends BaseHttpHandler<BaseResponse<List<Book>>> {

        FavoriteHandler() {
            super(mView);
        }

        @Override
        public void onSuccess(BaseResponse<List<Book>> result) {
            if(mView != null) {
                mView.showContent();
                mView.showFavorite(result);
            }
        }
    }
}
